//
//  CardCollectionViewCell.m
//  徙游记-01
//
//  Created by hcios on 2017/7/10.
//  Copyright © 2017年 鹿林. All rights reserved.
//

#import "CardCollectionViewCell.h"

#import "UIImageView+WebCache.h"


#define FONT_NAME_LTH @"FZLanTingHeiS-R-GB"

@interface CardCollectionViewCell()

@property (weak, nonatomic) IBOutlet UIImageView *bgImageView;

@property (weak, nonatomic) IBOutlet UILabel *cnName;


@property (weak, nonatomic) IBOutlet UILabel *enName;


@property (weak, nonatomic) IBOutlet UIButton *glBtn;

@property (weak, nonatomic) IBOutlet UIButton *xcBtn;

@property (weak, nonatomic) IBOutlet UIButton *lxdBtn;

@property (weak, nonatomic) IBOutlet UIButton *ztBtn;



@end

@implementation CardCollectionViewCell

-(void)awakeFromNib{
    [super awakeFromNib];
    [self setupSubViews];
}

-(void)setupSubViews{
    
    [self.cnName setFont:[UIFont fontWithName:FONT_NAME_LTH size:18]];
    [self.cnName setTextColor:[UIColor whiteColor]];
    self.cnName.shadowColor = [UIColor grayColor];
    self.cnName.shadowOffset = CGSizeMake(1, 1);
    
    [self.enName setFont:[UIFont fontWithName:FONT_NAME_LTH size:16]];
    [self.enName setTextColor:[UIColor whiteColor]];
    self.enName.shadowColor = [UIColor grayColor];
    self.enName.shadowOffset = CGSizeMake(1, 1);
    
    self.bgImageView.layer.cornerRadius = 4;
    self.bgImageView.layer.masksToBounds = YES;
    self.bgImageView.contentMode = UIViewContentModeScaleAspectFill;
    
    self.backgroundColor = [UIColor whiteColor];
    self.layer.cornerRadius = 10;
    self.layer.masksToBounds = YES;
    
    //图片设置
    CGFloat buttonH = _glBtn.frame.size.height;
    CGFloat buttonW = _glBtn.frame.size.width;
    [_glBtn setImage:[UIImage imageNamed:@"攻略"] forState:UIControlStateNormal];
    [_glBtn setImageEdgeInsets:UIEdgeInsetsMake(10, (buttonW - 35)/2, 30, (buttonW - 35)/2)];
    
    [_xcBtn setImage:[UIImage imageNamed:@"行程"] forState:UIControlStateNormal];
    [_xcBtn setImageEdgeInsets:UIEdgeInsetsMake(10, (buttonW - 35)/2, 30, (buttonW - 35)/2)];
    
    [_lxdBtn setImage:[UIImage imageNamed:@"目的地"] forState:UIControlStateNormal];
    [_lxdBtn setImageEdgeInsets:UIEdgeInsetsMake(10, (buttonW - 35)/2, 30, (buttonW - 35)/2)];
    
    [_ztBtn setImage:[UIImage imageNamed:@"专题"] forState:UIControlStateNormal];
    [_ztBtn setImageEdgeInsets:UIEdgeInsetsMake(10, (buttonW - 35)/2, 30, (buttonW - 35)/2)];
    
    //文字设置
    [_glBtn setTitleEdgeInsets:UIEdgeInsetsMake(buttonH - 20, -35, 0, 0)];
    [_xcBtn setTitleEdgeInsets:UIEdgeInsetsMake(buttonH - 20, -35, 0, 0)];
    [_lxdBtn setTitleEdgeInsets:UIEdgeInsetsMake(buttonH - 20, -35, 0, 0)];
    [_ztBtn setTitleEdgeInsets:UIEdgeInsetsMake(buttonH - 20, -35, 0, 0)];
}

-(void)setModel:(CardModel *)model{
    [self.bgImageView sd_setImageWithURL:[NSURL URLWithString:model.city_image_url] placeholderImage:[UIImage imageNamed:@"zhanWeiTu"]];
    self.cnName.text = model.city_name_zh_cn;
    self.enName.text = model.city_name_en;
}


- (IBAction)didClickGlBtn:(id)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(gl:)]) {
        [[[self.glBtn superview] superview] class];
        [self.delegate gl:sender];
    }
}

- (IBAction)didClickXcBtn:(id)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(xc:)]) {
        [self.delegate xc:sender];
    }
}

- (IBAction)didClickLxdBtn:(id)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(lxd:)]) {
        [self.delegate lxd:sender];
    }
}

- (IBAction)didClickZtBtn:(id)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(zt:)]) {
        [self.delegate zt:sender];
    }
    
}


@end
